package com.chance.cc.crawler.development.bootstrap.foodmate.tag;

import com.chance.cc.crawler.core.CrawlerEnum;
import com.chance.cc.crawler.core.filter.FilterUtils;
import com.chance.cc.crawler.core.record.CrawlerRequestRecord;
import com.chance.cc.crawler.development.controller.DevCrawlerController;

public class FoodMateBootstrap {

    public static final String domain = "foodmate";

    public static final String site = "search";

    public static void main(String[] args) {


        long time = System.currentTimeMillis();
        CrawlerRequestRecord requestRecord =CrawlerRequestRecord.builder()
                .startPageRequest(domain, CrawlerEnum.CrawlerRequestType.turnPage)
                .domain(domain)
                .httpUrl("http://news.foodmate.net/tag_1399.html")
                .recordKey("http://news.foodmate.net/tag_1399.html")
                .releaseTime(time)
                .filter(CrawlerEnum.CrawlerRecordFilter.keyOrDateRange)
                .addFilterInfo(FilterUtils.memoryFilterKeyInfo(domain))
                .addFilterInfo(FilterUtils.dateRangeFilterInfo(7*24,null))
                .build();

        requestRecord.tagsCreator().bizTags().addDomain(domain);
        requestRecord.tagsCreator().bizTags().addSite(site);
        requestRecord.getHttpRequest().addExtra("url","http://news.foodmate.net/search.php?kw=%s&catid=0&order=2&page=1");

        CrawlerRequestRecord keywordRecord = CrawlerRequestRecord.builder()
                .startPageRequest(domain, CrawlerEnum.CrawlerRequestType.turnPageItem)
                .httpUrl("http://192.168.1.217:9599/v1/meta/foodmate/keys?site=search")
                .requestLabelTag(CrawlerEnum.CrawlerRequestType.supportSource)
                .requestLabelTag(CrawlerEnum.CrawlerRequestType.internalDownload)
                .build();


        DevCrawlerController.builder()
                .triggerInfo(domain,domain,System.currentTimeMillis(),domain)
                .crawlerRequestQueue(DevCrawlerController.devRequestQueue(domain))
                .consoleResultPipeline()
                .fileResultPipeline("D:\\chance\\log\\footmate.log", false)
                .requestRecord(requestRecord)
                .supportRecord(keywordRecord)
                .build("com.chance.cc.crawler.development.scripts.foodmate.tag")
                .start();
    }
}
